package pl.asoft.nbp.dao;

import pl.asoft.nbp.model.ExchangeRate;

import java.util.Date;
import java.util.List;

/**
 * Created by rbiedrawa on 2014-12-02.
 */
public interface ExchangeRateDAO extends PersistentObjectDAO<ExchangeRate, Long> {

    //Named Queries
    String FIND_BY_DATE = "ExchangeRate.findByDate";
    String FIND_BY_SHORT_NAME = "ExchangeRate.findByShortName";
    String FIND_BY_SHORT_NAME_AND_DATE = "ExchangeRate.findByShortNameAndDate";
    String FIND_BY_SHORT_NAME_ORDER_BY_PRICE_DESC = "ExchangeRate.findByShortNameOrderByPriceDESC";
    String FIND_BY_SHORT_NAME_ORDER_BY_PRICE_ASC = "ExchangeRate.findByShortNameOrderByPriceASC";

    String FIND_WITH_MAX_PRICE = "ExchangeRate.withMaxPrice";
    String FIND_WITH_MAX_PRICE_AND_DATE_BETWEEN = "ExchangeRate.withMaxPriceAndDateBetween";
    String MAX_PRICE_AND_DATE_BETWEEN = "ExchangeRate.withMaxPriceAndDateBetweenWithoutShortName";

    String FIND_WITH_MIN_PRICE = "ExchangeRate.withMinPrice";
    String FIND_WITH_MIN_PRICE_AND_DATE_BETWEEN = "ExchangeRate.withMinPriceAndDateBetween";

    String GET_AVERAGE = "ExchangeRate.Average";
    String GET_AVERAGE_FROM_DATES = "ExchangeRate.AverageFromDates";
    String ABOVE_AVERAGE = "ExchangeRate.aboveAverage";
    String BELOW_AVERAGE = "ExchangeRate.belowAverage";

    List<ExchangeRate> findAllByDateBetween(String currency, Date startDate, Date endDate);

    List<ExchangeRate> findByDate(Date date);
    List<ExchangeRate> findByShortName(String shortName);
    ExchangeRate findByShortNameAndDate(String shortName, Date date);

    List<ExchangeRate> findAllWithMaxPriceLimit(String shortName, int limitResult);
    List<ExchangeRate> findAllWithMinPriceLimit(String shortName, int limitResult);

    List<ExchangeRate> findExchangeRateWithMaxPrice(String shortName);
    List<ExchangeRate> findExchangeRateWithMaxPrice(String shortName, Date startDate, Date endDate);
    ExchangeRate findExchangeRateWithMaxPrice(Date startDate, Date endDate);

    List<ExchangeRate> findExchangeRateWithMinPrice(String shortName);
    List<ExchangeRate> findExchangeRateWithMinPrice(String shortName, Date startDate, Date endDate);

    Double findExchangeRateAverage(String shortName);
    Double findExchangeRateAverage(String shortName,Date startDate, Date endDate );

    List<ExchangeRate> findAllBelowAverage(String shortName);
    List<ExchangeRate> findAllAboveAverage(String shortName);

    List<ExchangeRate> findAllExistingEagerLoad();

}
